﻿@model Kooboo.CMS.Membership.Models.Membership
@using Kooboo.CMS.Membership.Services;
@using Kooboo.CMS.Common.Runtime;

@{
    var routeValues = ViewContext.RequestContext.AllRouteValues().Merge("membershipName", Model.Name);


    var userManager = EngineContext.Current.Resolve<MembershipUserManager>();
    var connectManager = EngineContext.Current.Resolve<MembershipConnectManager>();
    var siteManager = EngineContext.Current.Resolve<SiteManager>();

    var users = userManager.All(Model, "").Count();
    var connects = connectManager.All(Model, "").Count();
    var sites = siteManager.All().Select(it => it.AsActual()).Where(it => it.Repository.EqualsOrNullEmpty(Model.Name, StringComparison.OrdinalIgnoreCase)).Count();
}
<div class="content-block membership">
    <div class="content-block-header @(sites > 0 ? "inused" : "notused")">
        @Html.ActionLink(Model.Name, "Go", "Membership", routeValues, new RouteValueDictionary(new { title = Model.Name }))
        <input type="radio" name="select" class="select" value="@Model.UUID" id="@Model.UUID"  data-id-property="UUID"><label for="@Model.UUID"></label><span class="corner"></span>
    </div>

    <ul>
        <li>
            @("Users:") @(users)
        </li>

        <li>
            @("Connects:") @(connects)
        </li>
        <li>
            @("Sites in use:") @sites
        </li>
    </ul>
</div>
